/*
*   GENERAZIONE TABELLE DI SISTEMA, SERVER SQL SERVER 2000
*
*
*   GENERAZIONE TABELLE DI SISTEMA
*
*	tb_regedit_tab - Registro di sistema
*	tb_attacchi - tabella per i log di sistema
*   tb_firewall - tabella per la gestione del firewall di sistema
*	tb_spiders_list - tabella per il gestore anti spyware
*	tb_users - tabella per gli utenti di sistema
*	tb_users_ping - tabella per tenere traccia degli utenti connessi
*	tb_blocchi - tabella per i blocchi di sistema
*	tb_moduli - tabella per i moduli di sistema
*	tb_articles - tabella per gli articoli
*	tb_pages - tabella delle pagine di contenuto
*	tb_pages_trad - tabella per le traduzioni delle pagine di contenuto
*
*
*   GENERAZIONE TABELLE PER I MODULI DI SISTEMA DI BASE
*
*	tb_mail_archive - archivio delle newsletter inviate agli utenti
*	tb_mail_signature - tabella per le signature delle mail
*	tb_maillist - tabella per la lista delle newsletter di sistema
*   tb_newsletter - tabella per gli utenti registrati alle newsletter
*
*/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_articles]') AND type in (N'U'))
DROP TABLE [dbo].[tb_articles]
BEGIN
CREATE TABLE [dbo].[tb_articles](
	[ID_ARTICOLO] [int] IDENTITY(1,1) NOT NULL,
	[NOME_ARTICOLO] [nvarchar](100) NULL DEFAULT (NULL),
	[ID_AUTORE] [int] NULL DEFAULT (NULL),
 CONSTRAINT [tb_articles_PRIMARY] PRIMARY KEY NONCLUSTERED 
(
	[ID_ARTICOLO] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_attacchi]') AND type in (N'U'))
DROP TABLE [dbo].[tb_attacchi]
BEGIN
CREATE TABLE [dbo].[tb_attacchi](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Utente] [nvarchar](50) NULL DEFAULT (NULL),
	[Ip] [nvarchar](50) NULL DEFAULT (NULL),
	[Messaggio] [nvarchar](200) NULL DEFAULT (NULL),
	[Ora] [nvarchar](50) NULL DEFAULT (NULL)
) ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_blocchi]') AND type in (N'U'))
DROP TABLE [dbo].[tb_blocchi]
BEGIN
CREATE TABLE [dbo].[tb_blocchi](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ID_ordine] [int] NULL DEFAULT (NULL),
	[STR_TITOLO] [nvarchar](50) NULL DEFAULT (NULL),
	[NOMEFILE] [nvarchar](50) NULL DEFAULT (NULL),
	[STR_POSIZIONE] [nvarchar](1) NULL DEFAULT (NULL),
	[STR_AUTORIZZAZIONE] [nvarchar](1) NULL DEFAULT (NULL),
	[BOL_ATTIVO] [tinyint] NOT NULL DEFAULT (N'0'),
	[STR_TIPO] [nvarchar](1) NULL DEFAULT (NULL),
	[MEM_CONTENT] [ntext] NULL DEFAULT (NULL)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_users_ping]') AND type in (N'U'))
DROP TABLE [dbo].[tb_users_ping]
BEGIN
CREATE TABLE [dbo].[tb_users_ping](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Us] [nvarchar](50) NULL DEFAULT (NULL),
	[Ping] [int] NULL DEFAULT (NULL)
) ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_firewall]') AND type in (N'U'))
DROP TABLE [dbo].[tb_firewall]
BEGIN
CREATE TABLE [dbo].[tb_firewall](
	[FW_ID] [int] IDENTITY(1,1) NOT NULL,
	[FW_IP] [nvarchar](50) NULL DEFAULT (NULL),
	[FW_IP_RULE] [nvarchar](50) NULL DEFAULT (NULL)
) ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_mail_archive]') AND type in (N'U'))
DROP TABLE [dbo].[tb_mail_archive]
BEGIN
CREATE TABLE [dbo].[tb_mail_archive](
	[mailID] [int] NOT NULL DEFAULT ((0)),
	[mailDate] [nvarchar](50) NULL DEFAULT (NULL),
	[mailFromEmail] [nvarchar](100) NULL DEFAULT (NULL),
	[mailSubject] [nvarchar](255) NULL DEFAULT (NULL),
	[mailBody] [ntext] NULL DEFAULT (NULL),
	[mailSig] [ntext] NULL DEFAULT (NULL),
	[mailNumber] [int] NULL DEFAULT (NULL),
	[mailOwner] [int] NULL DEFAULT (NULL),
	[listName] [nvarchar](100) NULL DEFAULT (NULL)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_mail_signature]') AND type in (N'U'))
DROP TABLE [dbo].[tb_mail_signature]
BEGIN
CREATE TABLE [dbo].[tb_mail_signature](
	[signatureID] [int] IDENTITY(1,1) NOT NULL,
	[signatureName] [nvarchar](50) NULL DEFAULT (NULL),
	[signature] [ntext] NULL DEFAULT (NULL),
	[sent] [int] NULL DEFAULT (NULL),
	[idCont] [int] NULL DEFAULT (NULL)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_maillist]') AND type in (N'U'))
DROP TABLE [dbo].[tb_maillist]
BEGIN
CREATE TABLE [dbo].[tb_maillist](
	[listID] [int] IDENTITY(1,1) NOT NULL,
	[listName] [nvarchar](50) NULL DEFAULT (NULL)
) ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_moduli]') AND type in (N'U'))
DROP TABLE [dbo].[tb_moduli]
BEGIN
CREATE TABLE [dbo].[tb_moduli](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Nome] [nvarchar](50) NULL DEFAULT (NULL),
	[table_to_remove] [ntext] NULL DEFAULT (NULL),
	[data] [nvarchar](50) NULL DEFAULT (NULL),
	[file_to_remove] [ntext] NULL DEFAULT (NULL)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_newsletter]') AND type in (N'U'))
DROP TABLE [dbo].[tb_newsletter]
BEGIN
CREATE TABLE [dbo].[tb_newsletter](
	[listID] [int] IDENTITY(1,1) NOT NULL,
	[ident] [int] NULL DEFAULT (NULL),
	[email] [nvarchar](50) NULL DEFAULT (NULL),
	[data] [nvarchar](50) NULL DEFAULT (NULL)
) ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_pages]') AND type in (N'U'))
DROP TABLE [dbo].[tb_pages]
BEGIN
CREATE TABLE [dbo].[tb_pages](
	[PG_ID] [int] IDENTITY(1,1) NOT NULL,
	[PG_NAME] [nvarchar](50) NULL DEFAULT (NULL),
	[PG_SAM] [nvarchar](50) NULL DEFAULT (NULL),
	[PG_TEMPLATE] [nvarchar](50) NULL DEFAULT (NULL),
	[PG_OWNER] [int] NULL DEFAULT (NULL),
	[PG_DATACREAZIONE] [nvarchar](50) NULL DEFAULT (NULL),
	[PG_DATAULTIMAMOD] [nvarchar](50) NULL DEFAULT (NULL),
	[PG_TAGS] [nvarchar](255) NULL DEFAULT (NULL),
	[PG_ID_ARTICLE] [int] NULL DEFAULT (NULL),
	[PG_BLOC] [int] NULL DEFAULT (NULL)
) ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_pages_trad]') AND type in (N'U'))
DROP TABLE [dbo].[tb_pages_trad]
BEGIN
CREATE TABLE [dbo].[tb_pages_trad](
	[TRAD_ID] [int] IDENTITY(1,1) NOT NULL,
	[TRAD_PAGE] [int] NULL DEFAULT (NULL),
	[TRAD_CONTENT] [ntext] NULL DEFAULT (NULL),
	[TRAD_LING] [nvarchar](50) NULL DEFAULT (NULL),
	[TRAD_NAME] [nvarchar](50) NULL DEFAULT (NULL),
	[TRAD_OWNER] [int] NULL DEFAULT (NULL)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_regedit_tab]') AND type in (N'U'))
DROP TABLE [dbo].[tb_regedit_tab]
BEGIN
CREATE TABLE [dbo].[tb_regedit_tab](
	[SYSTEM_ID] [int] IDENTITY(1,1) NOT NULL,
	[SYSTEM_LING_DEFAULT] [nvarchar](50) NULL DEFAULT (NULL),
	[SYSTEM_INDEX_DEFAULT] [nvarchar](50) NULL DEFAULT (NULL),
	[SYSTEM_PAGE_DEFAULT] [nvarchar](50) NULL DEFAULT (NULL),
	[SYSTEM_HOME_TYPE] [nvarchar](50) NULL DEFAULT (NULL),
	[SYSTEM_ADM_INDEX_DEFAULT] [nvarchar](50) NULL DEFAULT (NULL),
	[SYSTEM_STRING_TITLE] [nvarchar](255) NULL DEFAULT (NULL),
	[SYSTEM_THEME_DEFAULT] [nvarchar](50) NULL DEFAULT (NULL),
	[SYSTEM_BLOC_SX_DEFAULT] [tinyint] NULL DEFAULT (NULL),
	[SYSTEM_BLOC_DX_DEFAULT] [tinyint] NULL DEFAULT (NULL),
	[SYSTEM_URL_REMOTE] [nvarchar](50) NULL DEFAULT (NULL),
	[SYSTEM_URL] [nvarchar](255) NULL DEFAULT (NULL),
	[SYSTEM_MAIL_ADMIN] [nvarchar](150) NULL DEFAULT (NULL),
	[SYSTEM_MAIL_WEB] [nvarchar](150) NULL DEFAULT (NULL),
	[SYSTEM_MAIL_INFO] [nvarchar](150) NULL DEFAULT (NULL),
	[SYSTEM_META_KEY] [nvarchar](150) NULL DEFAULT (NULL),
	[SYSTEM_META_DESC] [nvarchar](255) NULL DEFAULT (NULL),
	[SYSTEM_META_AUTOR] [nvarchar](150) NULL DEFAULT (NULL),
	[SYSTEM_ADM_VISIB] [nvarchar](1) NULL DEFAULT (NULL),
	[SYSTEM_SERVER_ADDR] [nvarchar](50) NULL DEFAULT (NULL),
	[SYSTEM_MAIL_COMPONENT] [nvarchar](50) NULL DEFAULT (NULL),
	[SYSTEM_LING_AUTO] [tinyint] NOT NULL DEFAULT (N'0'),
	[SYSTEM_SECURITY_LEVEL] [int] NULL DEFAULT (NULL),
	[SYSTEM_SESSION_TIMEOUT] [int] NULL DEFAULT (NULL),
	[SYSTEM_PASSWORD_CRITTOGRAFY] [nvarchar](50) NULL DEFAULT (NULL),
	[SYSTEM_DATE_TYPE] [nvarchar](50) NULL DEFAULT (NULL),
	[SYSTEM_TIME_TYPE] [int] NULL DEFAULT (NULL),
	[SYSTEM_TIME_ADJUST] [int] NULL DEFAULT (NULL),
	[SYSTEM_STATUS] [tinyint] NULL DEFAULT (NULL),
	[SYSTEM_STATUS_MSG] [ntext] NULL DEFAULT (NULL),
	[SYSTEM_SHOW_TRAD] [tinyint] NOT NULL DEFAULT (N'0'),
	[SYSTEM_SPYBOT_LOCK] [nvarchar](1) NULL DEFAULT (NULL),
	[SYSTEM_SPYBOT_LOG] [nvarchar](1) NULL DEFAULT (NULL),
	[SYSTEM_SPYBOT_MAIL] [nvarchar](1) NULL DEFAULT (NULL),
	[SYSTEM_FIREWALL_STATE] [nvarchar](50) NULL DEFAULT (NULL),
	[SYSTEM_FIREWALL_LOG] [nvarchar](1) NULL DEFAULT (NULL),
	[SYSTEM_EDITOR_LING] [nvarchar](50) NULL DEFAULT (NULL),
	[SYSTEM_EDITOR_RETURN] [nvarchar](1) NULL DEFAULT (NULL),
	[SYSTEM_EDITOR_TOOL] [nvarchar](1) NULL DEFAULT (NULL),
	[SYSTEM_PATH_IMG] [nvarchar](255) NULL DEFAULT (NULL),
	[SYSTEM_PAGE_TRAD] [tinyint] NOT NULL DEFAULT (N'0'),
	[SYSTEM_PASS_CRYPT] [nvarchar](50) NULL DEFAULT (NULL),
	[SYSTEM_SMTP_USER] [nvarchar](255) NULL DEFAULT (NULL),
	[SYSTEM_SMTP_PASS] [nvarchar](255) NULL DEFAULT (NULL),
	[SYSTEM_PING_TIMER] [int] NULL DEFAULT (NULL),
	[SYSTEM_PING] [tinyint] NULL DEFAULT (NULL)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_spiders_list]') AND type in (N'U'))
DROP TABLE [dbo].[tb_spiders_list]
BEGIN
CREATE TABLE [dbo].[tb_spiders_list](
	[SPIDER_NAME] [nvarchar](200) NULL DEFAULT (NULL),
	[SPIDER_ID] [int] NOT NULL DEFAULT ((0))
) ON [PRIMARY]
END
;
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_users]') AND type in (N'U'))
DROP TABLE [dbo].[tb_users]
BEGIN
CREATE TABLE [dbo].[tb_users](
	[Uid] [int] IDENTITY(1,1) NOT NULL,
	[Uname] [nvarchar](50) NULL DEFAULT (NULL),
	[Upass] [nvarchar](255) NULL DEFAULT (NULL),
	[CryptoPass] [nvarchar](50) NULL DEFAULT (NULL),
	[Nome] [nvarchar](50) NULL DEFAULT (NULL),
	[Cognome] [nvarchar](50) NULL DEFAULT (NULL),
	[Email] [nvarchar](50) NULL DEFAULT (NULL),
	[Emailvisib] [tinyint] NOT NULL DEFAULT (N'0'),
	[Regione] [nvarchar](50) NULL DEFAULT (NULL),
	[Provincia] [nvarchar](50) NULL DEFAULT (NULL),
	[Dataregistrazione] [nvarchar](50) NULL DEFAULT (NULL),
	[Sig] [nvarchar](255) NULL DEFAULT (NULL),
	[LastLoggedIn] [nvarchar](50) NULL DEFAULT (NULL),
	[Website] [nvarchar](255) NULL DEFAULT (NULL),
	[LivelloUser] [int] NULL DEFAULT (NULL),
	[AutorizzazioniADM] [ntext] NULL DEFAULT (NULL),
	[AutorizzazioniMOD] [ntext] NULL DEFAULT (NULL),
	[Anni] [nvarchar](3) NULL DEFAULT (NULL),
	[Hobby] [nvarchar](255) NULL DEFAULT (NULL),
	[Occhi] [nvarchar](50) NULL DEFAULT (NULL),
	[Foto] [nvarchar](255) NULL DEFAULT (NULL),
	[MiaDesc] [nvarchar](255) NULL DEFAULT (NULL),
	[AltriDesc] [nvarchar](255) NULL DEFAULT (NULL),
	[Link1] [nvarchar](255) NULL DEFAULT (NULL),
	[Link2] [nvarchar](255) NULL DEFAULT (NULL),
	[Link3] [nvarchar](255) NULL DEFAULT (NULL),
	[Link4] [nvarchar](255) NULL DEFAULT (NULL),
	[CryptRecovery] [nvarchar](50) NULL DEFAULT (NULL),
	[CryptActivate] [nvarchar](50) NULL DEFAULT (NULL),
	[ICQ] [nvarchar](50) NULL DEFAULT (NULL),
	[MSN] [nvarchar](50) NULL DEFAULT (NULL),
	[YAHOO] [nvarchar](50) NULL DEFAULT (NULL),
	[AOL] [nvarchar](50) NULL DEFAULT (NULL),
	[SKYPE] [nvarchar](50) NULL DEFAULT (NULL),
	[Avatar] [nvarchar](255) NULL DEFAULT (NULL),
	[PAGE_LIMIT] [int] NULL DEFAULT (NULL),
	[STORE_LIMIT] [int] NULL DEFAULT (NULL)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
;